# -*- coding:utf-8 -*-
# 字典的循环遍历
# for循环
# 1、默认遍历key值
# dict1 = {"姓名": "张三", "年龄": 18, "性别": "男"}
# for data1 in dict1:
#     print(data1)

# 遍历key值
# dict1 = {"姓名": "张三", "年龄": 18, "性别": "男"}
# for data2 in dict1.keys():
#     print(data2)

# 2、遍历value
# dict1 = {"姓名": "张三", "年龄": 18, "性别": "男"}
# for data3 in dict1.values():
#     print(data3)

# 3、遍历所有的元素
# dict1 = {"姓名": "张三", "年龄": 18, "性别": "男"}
# for data4 in dict1.items():
#     # print(type(data4))    # 数据类型是元组
#     k, v = data4         # 拆包
#     print(k)    # 打印键
#     print(v)             # 打印值


# 小应用：
# 拿出单个值
dict1 = {"姓名": "张三", "年龄": 18, "性别": "男"}
for data1 in dict1.items():
    k, v = data1
    if v == "张三":
        print(v)
